package ControlLayer;

import ModelLayer.*;
import DBLayer.*;
import java.util.ArrayList;
/**
 *
 * @author Zlatko
 */
public class CustomerCtr {
    public CustomerCtr() {

    }
    public ArrayList<Customer> findAllCustomers()
    {
      DBCustomer dbCust = new DBCustomer();
      ArrayList allCust = new ArrayList();
      allCust = dbCust.getAllCustomers("");
      return allCust;
    }
    public Customer findByName(String name)
    {
    	DBCustomer dbCust = new DBCustomer();
        return dbCust.getByName(name);
    }

        public Customer findById(String id) {
        	DBCustomer dbCust = new DBCustomer();
                return dbCust.getById(id);
        }
        public Customer findByCity(String city) {
        	DBCustomer dbCust = new DBCustomer();
                return dbCust.getByCity(city);
        }
        public Customer findByPhone(String phone) {
        	DBCustomer dbCust = new DBCustomer();
                return dbCust.getCustomerByPhone(phone);
        }

      public Customer getCustomerById(String id)
    {
    	  DBCustomer dbCust = new DBCustomer();
        return dbCust.getById(id);
    }
      public void updateCustomer(String name, String address, String zipcode, String phone)
      {
    	  DBCustomer dbCust = new DBCustomer();
          Customer cust = new Customer();
          cust.setcustomerName(name);
          cust.setAddress(address);
          cust.setzipCode(zipcode);
          cust.setPhone(phone);
          
          dbCust.updateCustomer(cust);
      }

      public void insertNew(Customer custObj)
      {
    	  DBCustomer dbCust = new DBCustomer();
           dbCust.insertCustomer(custObj);
      }

      public void deleteCustomer(String phone){
    	  DBCustomer dbCust = new DBCustomer();
          dbCust.deleteCustomer(phone);
      }

}

